/// 评论列表
class CommentListResponse {
  List<CommentResponse> rows;
  int total;

  CommentListResponse({
    required this.rows,
    required this.total,
  });

  factory CommentListResponse.fromJson(Map<String, dynamic> json) =>
      CommentListResponse(
        total: json['total'] as int,
        rows: (json['rows'] as List)
            .map((e) => CommentResponse.fromJson(e))
            .toList(),
      );
}

class CommentResponse {
  int? commentId;
  int? myFlag;
  String? text;
  String? image;
  String? audio;
  int? audioDuration;
  String? countryName;
  String? provinceName;
  String? cityName;
  String? createTime;
  int? giveFlag;
  int? giveNum;
  int? childNum;
  int officialFlag;
  String? officialName;
  int? customerId;
  String? customerName;
  String? avatar;

  CommentResponse({
    this.commentId,
    this.myFlag,
    this.text,
    this.image,
    this.audio,
    this.audioDuration,
    this.countryName,
    this.provinceName,
    this.cityName,
    this.createTime,
    this.giveFlag,
    this.giveNum,
    this.childNum,
    this.officialFlag = 0,
    this.officialName,
    this.customerId,
    this.customerName,
    this.avatar,
  });

  factory CommentResponse.fromJson(Map<String, dynamic> json) {
    return CommentResponse(
      commentId: json['commentId'] as int?,
      myFlag: json['myFlag'] as int?,
      text: json['text'] as String?,
      image: json['image'] as String?,
      audio: json['audio'] as String?,
      audioDuration: json['audioDuration'] as int?,
      countryName: json['countryName'] as String?,
      provinceName: json['provinceName'] as String?,
      cityName: json['cityName'] as String?,
      createTime: json['createTime'] as String?,
      giveFlag: json['giveFlag'] as int?,
      giveNum: json['giveNum'] as int?,
      childNum: json['childNum'] as int?,
      officialFlag: (json['officialFlag'] as int?) ?? 0,
      officialName: json['officialName'] as String?,
      customerId: json['customerId'] as int?,
      customerName: json['customerName'] as String?,
      avatar: json['avatar'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'commentId': commentId,
        'myFlag': myFlag,
        'text': text,
        'image': image,
        'audio': audio,
        'audioDuration': audioDuration,
        'countryName': countryName,
        'provinceName': provinceName,
        'cityName': cityName,
        'createTime': createTime,
        'giveFlag': giveFlag,
        'giveNum': giveNum,
        'childNum': childNum,
        'officialFlag': officialFlag,
        'officialName': officialName,
        'customerId': customerId,
        'customerName': customerName,
        'avatar': avatar,
      };
}
